package com.itheima.health.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.health.UserService;
import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author likepei
 * @Date 2020/3/26 15:23
 * @Version v1.0
 * @Description 用户业务的控制器
 */

@RestController
@RequestMapping("web/user")
public class UserController {

    //依赖注入service对象
    @Reference
    private UserService userService;

    @RequestMapping("login")
    public Result login(String username, String password){
        System.out.println("health_oms_backend=====u:"+username+", p:"+password);

        //调用service的 用户登录方法
        if(userService.login(username, password)){
            //返回正确
            System.out.println("login succuss");
            return new Result(true, MessageConst.ACTION_SUCCESS);
        } else {
            //返回失败
            System.out.println("login fail");
            return new Result(false, MessageConst.ACTION_FAIL);
        }
    }
}
